package com.springboot.eurekaproviderdemo.controller;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class GoodsController {

    @GetMapping("/getGoods")
    public Goods getGoods() {
        Goods goods = new Goods();
        goods.setId((long) 1);
        goods.setTitle("小米");
        goods.setPrice(1299);
        return goods;
    }

    @GetMapping("/getGoodsList")
    public List<Goods> getGoodsList() {
        ArrayList<Goods> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Goods goods = new Goods();
            goods.setId((long) i+1);
            goods.setTitle("小米");
            goods.setPrice((i+1)*1000);
            list.add(goods);
        }
        return list;
    }
}
